//
//  CBJStatuesViewModel.swift
//  Weibo
//
//  Created by 崔健 on 16/5/25.
//  Copyright © 2016年 cbj. All rights reserved.
//

import UIKit

class CBJStatuesViewModel: NSObject {
    
    
    var statues : CBJStatues?
    var headerImageURL : NSURL?
    var timeFomate : String?{
    
        return (NSDate.sinaDate(statues?.created_at ?? "")?.fullDescription())!
    }
    
    var sourceText : String?
    
    init(statues:CBJStatues) {
        super.init()
        
        self.statues = statues
        deadlSourceText()
        headerImageURL = NSURL(string: (statues.user?.profile_image_url) ?? "")
        
    }
    
    func deadlSourceText(){
    
        let startFlag = "\">"
        let endFlag = "</a>"
        let startRange = statues?.source?.rangeOfString(startFlag)
        let endRange = statues?.source?.rangeOfString(endFlag)
        if let start = startRange , end = endRange {
            
            let range = start.endIndex ..< end.startIndex
            sourceText = statues?.source?.substringWithRange(range)
        }

    }
    

}
